/**
 * 
 */
package common.util.enums;

import java.util.Iterator;
import java.util.List;

/**
 * @author Administrator
 *
 */

public abstract class StringEnum extends Enum
{

    protected StringEnum(String name, String value)
    {
        super(name);
        sValue = value;
    }

    protected static Enum getEnum(Class enumClass, String value)
    {
        if(enumClass == null)
            throw new IllegalArgumentException("The Enum Class must not be null");
        List list = Enum.getEnumList(enumClass);
        for(Iterator it = list.iterator(); it.hasNext();)
        {
            StringEnum _enum = (StringEnum)it.next();
            if(_enum.getValue().equals(value))
                return _enum;
        }

        return null;
    }

    public final String getValue()
    {
        return sValue;
    }

    private final String sValue;
}

